package com.miaow.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.integration.support.MessageBuilder;

/**
 * @author HWZ
 * @date 2023年12月20日 15:54
 * @description
 */
public class MyService {
    @Autowired
    private MyProduct producer;

    @Autowired
    private MyConsumer consumer;

    public void sendMessage(String message) {
        producer.output().send(MessageBuilder.withPayload(message).build());
    }

    @StreamListener(MyConsumer.INPUT)
    public void receiveMessage(String message) {
        System.out.println("Received message: " + message);
    }
}
